import React from "react";
import {useLocation, useNavigate} from "react-router-dom";
import {Menu} from "antd";
import "./index.css";
import logo from '../../assets/img/logo.svg';


const Sidebar = (props) => {
	const { collapsed } = props;

	const navigate = useNavigate();

	const location = useLocation()

	const onMenuSelect = ({key}) => {
		navigate(key);
	}

	return (
		<div className="sidebar">
			<div className="sidabar-header">
				<img className="logo" src={logo} alt="" />
				{!collapsed && <span>管理系统</span>}
			</div>
			<Menu
				defaultSelectedKeys={[location.pathname]}
				theme="dark"
				mode="inline"
				onClick={onMenuSelect}
			/>
		</div>
	)
}
export default Sidebar;
